//
//  JGOnlyListenTableViewCell.m
//  MarianasTrench
//
//  Created by 付建国 on 16/3/19.
//  Copyright © 2016年 王爵. All rights reserved.
//

#import "JGOnlyListenTableViewCell.h"

@interface JGOnlyListenTableViewCell ()

@property (nonatomic, strong) UIImageView *imageV;
@property (nonatomic, strong) UILabel *titleL;
@property (nonatomic, strong) UILabel *nameL;
@property (nonatomic, strong) UILabel *timeL;

@end

@implementation JGOnlyListenTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubView];
    }
    return self;
}
- (void)createSubView{
    self.imageV = [[UIImageView alloc] init];
    [self.contentView addSubview:_imageV];
    
    self.timeL = [[UILabel alloc] init];
    [self.contentView addSubview:_timeL];
    
    self.titleL = [[UILabel alloc] init];
    [self.contentView addSubview:_titleL];
    
    self.nameL = [[UILabel alloc] init];
    [self.contentView addSubview:_nameL];
    
}

- (void)setModel:(ListModel *)model{
    _model = model;
    [self fuzhi];
}
- (void)fuzhi{
//    [self.imageV sd_setImageWithURL:[NSURL URLWithString:_model.coverSmall]];
    dispatch_async(dispatch_get_main_queue(), ^{
        
        [self.imageV HANDLEIMAGE(_model.coverSmall)];
    });
    
    NSString *titleStr = [NSString stringWithFormat:@"%@", _model.title];
    self.titleL.text = titleStr;
    self.titleL.numberOfLines = 10;
    self.titleL.font = [UIFont systemFontOfSize:15];
    
    NSString *nameStr = [NSString stringWithFormat:@"by%@", _model.nickname];
    self.nameL.text = nameStr;
    self.nameL.textColor = [UIColor grayColor];
    self.nameL.font = [UIFont systemFontOfSize:14];
    
    NSInteger num = [_model.duration integerValue];
    NSString *str = [NSString stringWithFormat:@"时间 : %2ld:%.2ld", num / 60, num % 60];
    self.timeL.text = str;
    self.timeL.textColor = [UIColor grayColor];
    self.timeL.font = [UIFont systemFontOfSize:12];
}
// 布局
- (void)layoutSubviews{
    [super layoutSubviews];
    self.imageV.frame = CGRectMake(10, 5, self.contentView.frame.size.height -10, self.contentView.frame.size.height - 10);
    
    self.titleL.frame = CGRectMake(self.contentView.frame.size.height + 5, 5, self.contentView.frame.size.width - self.contentView.frame.size.height - 10, 40);
    
    self.nameL.frame = CGRectMake(self.contentView.frame.size.height + 5, 50, self.contentView.frame.size.width - self.contentView.frame.size.height - 10, 20);
    
    self.timeL.frame = CGRectMake(self.contentView.frame.size.height + 5, 70, self.contentView.frame.size.width - self.contentView.frame.size.height - 10, 15);
}






- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end
